package cn.sciento.farm.devicemanager.service.impl;

import cn.sciento.farm.devicemanager.dao.entity.DevInsectImage;
import cn.sciento.farm.devicemanager.dao.mapper.DevInsectImageMapper;
import cn.sciento.farm.devicemanager.gateway.model.uplink.InsectLampSwitch;
import cn.sciento.farm.devicemanager.service.DevInsectImageService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Walton
 * @since 2020/9/7 14:50
 */
@Service
public class DevInsectImageServiceImpl implements DevInsectImageService {
    @Autowired
    private DevInsectImageMapper insectImageMapper;

    @Override
    public int insert(DevInsectImage devInsectImage) {
        devInsectImage.setCreateTime(System.currentTimeMillis());
        return insectImageMapper.insert(devInsectImage);
    }

    @Override
    public DevInsectImage getByInsectId(Long insectId) {
        QueryWrapper wrapper = new QueryWrapper<DevInsectImage>();
        wrapper.eq("insect_id",insectId);
        return insectImageMapper.selectOne(wrapper);
    }

    @Override
    public int update(DevInsectImage devInsectImage) {
        return insectImageMapper.updateById(devInsectImage);
    }

    @Override
    public List<DevInsectImage> getPhtotsImages(Long insectId, Long beginTime, Long endTime) {
        List<DevInsectImage> insectImages = insectImageMapper.getPhtotsImages(insectId, beginTime, endTime);
        return insectImages;
    }

}
